<?php
$page_lang = array(
  "en" => "en"  
);
/**
* language to load
*/
if(isset($_SESSION['lang'])){
    $lang = $_SESSION['lang'];
    /**
     * remote and local file inclusion validation
     */
    if(!in_array($lang,array_keys($page_lang))){
        $lang = "en";
    }
}
else {
    $lang = "en";
}
$files_to_load = array(
    "lang_file" => "./lang/".$lang.".php",
    "files_to_load" => "./configs/files_to_load.php"
);
try {
    foreach($files_to_load as $key => $value){
        if(file_exists($value)){
            require_once $value;
        }
        else {
            throw new Exception("Framework can't load file: <strong>".$value."</strong>!");
        }
    }
} catch (Exception $ex) {
    echo $ex->getMessage();
}
require_once SERVER_ROOT."page_links.php";
/**
 * error_reporting
 */
error_reporting(ERROR_REPORTING_LEVEL);
/**
 * autoloader()
 * @param type $class_name
 */
function __autoload($class_name){
    require_once './core/controllers/autoloader.php';
    $autoload = new Core_Controller_Autoloader;
    $autoload->class_to_load($class_name);
}
/**
 * session initialise
 */
$session = new Core_Controller_Session(SESSION_EXPIRE_TIME);
$session->main();
var_dump($_SESSION);
var_dump($_GET);
/**
 * test xss protection
 */
$variables = array(
    "get" => $_GET,
    "post" => $_POST,
    "server" => $_SERVER
);
$xss_protect = new Core_Controller_Xssprotection;
/**
 * initialise functionality
 */
$variables = $xss_protect->xss_entrypoint($variables, "all_xss_filters");
//var_dump($variables);
//$logger = new Core_Controller_Logger;
//$logger->main($variables['server']);

$query_string = $_SERVER['QUERY_STRING'];
$router = new Core_Controller_Router;
$class_init = $router->route($query_string);
$controller = new $class_init;
$controller->main($variables);